// common/models/auth/login_request.dart

/// 登录请求模型
/// 基于hello-auth-api.md定义
class LoginRequest {
  /// 用户名（长度：2-20）
  final String username;
  
  /// 密码（长度：5-20）
  final String password;
  
  const LoginRequest({
    required this.username,
    required this.password,
  });
  
  
  /// 从JSON创建实例
  factory LoginRequest.fromJson(Map<String, dynamic> json) {
    return LoginRequest(
      username: json['username'] as String,
      password: json['password'] as String,
    );
  }
  
  /// 转换为JSON
  Map<String, dynamic> toJson() {
    return {
      'username': username,
      'password': password,
    };
  }
  
  @override
  String toString() {
    return 'LoginRequest(username: $username, password: [HIDDEN])';
  }
  
  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;
    return other is LoginRequest &&
        other.username == username &&
        other.password == password;
  }
  
  @override
  int get hashCode => username.hashCode ^ password.hashCode;
}
